/*
 * Copyright (C) 2012, EADS France
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.gmi.controller;

/**
 *
 * @author Laurent WOUTERS
 */
public class GraphConnectorSetPorts extends NodeAction {
    private int oldFromPID;
    private int oldToPID;
    private int newFromPID;
    private int newToPID;
    
    public GraphConnectorSetPorts(xowl.interpreter.Repository repository, String parent, String child, int oldFromPID, int oldToPID, int newFromPID, int newToPID) {
        super("Setting connector ports", repository, parent, child);
        this.repository = repository;
        this.oldFromPID = oldFromPID;
        this.oldToPID = oldToPID;
        this.newFromPID = newFromPID;
        this.newToPID = newToPID;
    }
    
    @Override public void execute() { redo(); }
    @Override public void undo() {
        xowl.gmi.model.ast.Decorator decorator = getDecorator();
        decorator.setOriginPort(oldFromPID);
        decorator.setTargetPort(oldToPID);
    }
    @Override public void redo() {
        xowl.gmi.model.ast.Decorator decorator = getDecorator();
        decorator.setOriginPort(newFromPID);
        decorator.setTargetPort(newToPID);
    }
}
